#ifndef __IPZ_ZBC_EXTERN_H_
#define __IPZ_ZBC_EXTERN_H_

#ifdef		IPZ_ZBC_EXTERN
#define		IPZ_ZBC_EXT		
#else
#define		IPZ_ZBC_EXT	extern
#endif

#define  SW_SERIAL_UAERT0               0
#define  SW_SERIAL_UAERT1				1
#define  SW_SERIAL_UAERT2				2
#define  SW_SERIAL_UAERT3				3

#define  VD_READ_NONE					0
#define  VD_READ_AFD					1	

#define  AFD_READ_NONE					0
#define  AFD_READ_AFD					1		
#define  AFD_READ_AFD_2     		    5  		

#define  AED_READ_NONE					0
#define  AED_READ_AED					1		


#define	SOFT_VERSION		            100
#define	IPZ_ZBC_DEV_ZOOM_LOCK           1
#define	IPZ_ZBC_DEV_FOCUS_LOCK          1



 #define  IPZ_ZBC_CONFIG_PROJECT_NAME "ZBC"
 #define  IPZ_ZBC_CONFIG_PROJECT_VERSION_MAJOR   1
 #define  IPZ_ZBC_CONFIG_PROJECT_VERSION_MINOR   0
 #define  IPZ_ZBC_CONFIG_PROJECT_VERSION_PATCH   0
 
typedef enum _IPZ_ZBC_INQ_TYPE
{
    IPZ_ZBC_INQ_DOME = 1,
    IPZ_ZBC_INQ_NUM, 
}IPZ_ZBC_INQ_TYPE;

typedef enum _IPZ_ZBC_SET_TYPE
{
    IPZ_ZBC_SET_FIZ = 1,
    IPZ_ZBC_SET_PARAM = 2,
    IPZ_ZBC_SET_T2 = 3,
    IPZ_ZBC_SET_NUM, 
}IPZ_ZBC_SET_TYPE;


typedef enum
{
	/*返回int类型，范围0x0-0x7ac0*/
	INQ_IPZOOM_ZOOMPOS,
	/*返回int类型，范围0x1000-0xc000*/
	INQ_IPZOOM_FOCUSPOS,
	/*返回int类型，高16位中高8为为版本号高字节低8位为版本号低字节，
	低16位高8为为build日期年月，低8为为build日期日
	0x012CD817表示，V1.44build130823	*/
	INQ_IPZOOM_SOFTVER,
	/*返回u8类型1为白天0为黑夜*/
	INQ_IPZOOM_ICR_STA,
	/*返回int类型，范围0x1 - 141(IMX122,IMX138),241(9M033),791(ar0331)*/
	INQ_IPZOOM_AGC,
	/*返回int类型，1表示机芯电机启动完成*/
	INQ_IPZOOM_POWERON,
	/*返回BOOL类型，1表示电机运动由球机控制*/
	INQ_IPZOOM_MOTOR_HOST,
	/*返回BOOL类型，1表示球机连接，球机连接主要用于自动扫描命令和
	通过232发送巡航启动、停止信息的控制*/
	INQ_IPZOOM_DOME_CONNECT
}InqIPZoomInfo;



typedef enum
{
	SET_IPZOOM_PARAM,
	INQ_IPZOOM_INFO,
	IPZ_CMD_NUM
}CmdToIPZoom;

typedef enum _IPZ_ZBC_FIZ_CMD
{
    IPZ_ZBC_FIZ_CMD_BEG = 0,

    IPZ_ZBC_FIZ_ZOOM_WIDE,				
    IPZ_ZBC_FIZ_ZOOM_TELE,
    IPZ_ZBC_FIZ_ZOOM_STOP,
    IPZ_ZBC_FIZ_FOCUS_FAR,				
    IPZ_ZBC_FIZ_FOCUS_NEAR = 5,				
    IPZ_ZBC_FIZ_FOCUS_STOP,

    IPZ_ZBC_FIZ_IRIS_CLOSE,				
    IPZ_ZBC_FIZ_IRIS_OPEN,	

    IPZ_ZBC_FIZ_IRCUT,				
    IPZ_ZBC_FIZ_IRCUT_NONE = 10,//接口调整，没有使用这个cmd

    IPZ_ZBC_FIZ_ONE_PUSH_FOCUS,		
    IPZ_ZBC_FIZ_RESET_LENS,			
    IPZ_ZBC_FIZ_ZONE_FOCUS,
    IPZ_ZBC_FIZ_PANTILT_STATE,
    IPZ_ZBC_FIZ_SET_DOME_MODE,
    
    IPZ_ZBC_FIZ_SET_DOME_DETECT = 16,
    IPZ_ZBC_FIZ_SET_DOME_TIMEOUT,

    IPZ_ZBC_OIS_SERVER_START = 20,
    IPZ_ZBC_OIS_SERVER_STOP,
    IPZ_ZBC_OIS_START,
    IPZ_ZBC_OIS_STOP,
    IPZ_ZBC_OIS_LOCK,
    IPZ_ZBC_OIS_UNLOCK,
    IPZ_ZBC_OIS_PTZ_START,
    IPZ_ZBC_OIS_PTZ_STOP,

	IPZ_ZBC_FIZ_CMD_END
}IPZ_ZBC_FIZ_CMD;

typedef enum _IPZ_ZBC_PARAM_CMD
{
    IPZ_ZBC_PARAM_CMD_BEG = 0,
    IPZ_ZBC_PARAM_FOCUS_MODE,
    IPZ_ZBC_PARAM_DZOOM_MODE,
    IPZ_ZBC_PARAM_AF_MODE,
    IPZ_ZBC_PARAM_AF_SENSE,
    IPZ_ZBC_PARAM_AF_LIMIT = 5,
    IPZ_ZBC_PARAM_DZOOM_LIMIT,
    IPZ_ZBC_PARAM_AF_AREA,
    IPZ_ZBC_PARAM_ZOOM_SPEED,
    IPZ_ZBC_PARAM_FPS,
    IPZ_ZBC_PARAM_RESOLUTION = 10,
    IPZ_ZBC_PARAM_WDR_MODE,
    IPZ_ZBC_PARAM_DEVTYPE,
    IPZ_ZBC_PARAM_IRIS_VALUE,
    IPZ_ZBC_PARAM_IRIS_TYPE,
    IPZ_ZBC_PARAM_IRIS_MAXLIMIT = 15,
    IPZ_ZBC_PARAM_IRIS_MINLIMIT,
    IPZ_ZBC_PARAM_MIRROR_STATE,
    IPZ_ZBC_PARAM_TEMPDECT_STATE = 18,
    IPZ_ZBC_PARAM_RS232_CONTROL_MODE,
    IPZ_ZBC_PARAM_PRESET_FOCUS_MODE = 20,
    
    IPZ_ZBC_PARAM_CMD_END
}IPZ_ZBC_PARAM_CMD;

typedef enum _IPZ_ZBC_T2_CMD
{
    IPZ_ZBC_T2_CMD_BEG = 0,
    IPZ_ZBC_T2_INIT,
    IPZ_ZBC_T2_IRIS,
    IPZ_ZBC_T2_PI,
    IPZ_ZBC_T2_INF,
    IPZ_ZBC_T2_IM5,
    IPZ_ZBC_T2_EXIT,		
    IPZ_ZBC_T2_CMD_END
}IPZ_ZBC_T2_CMD;

typedef enum _IPZ_ZBC_DOME_CMD
{
    IPZ_ZBC_DOME_CMD_BEG = 0,
    IPZ_ZBC_DOME_CMD_STATUS,
    IPZ_ZBC_DOME_FOCUS_STATUS,
    IPZ_ZBC_DOME_ZOOM_STATUS,
    IPZ_ZBC_DOME_PTMOTOR_STATUS,
    IPZ_ZBC_DOME_CMD_END
}IPZ_ZBC_DOME_CMD;

//SW_SEM		UartSem;
IPZ_ZBC_EXT SW_SEM		pMotorSem;		//电机运动
IPZ_ZBC_EXT SW_SEM		pIrisSem;
IPZ_ZBC_EXT SW_SEM      pReadAESem;
IPZ_ZBC_EXT SW_SEM 		pAFDSem;		//读AF数据信号量
IPZ_ZBC_EXT SW_SEM 		pAEDSem;		//读AE数据信号量
IPZ_ZBC_EXT SW_SEM 		pVDSem;			//Vd同步信号
IPZ_ZBC_EXT SW_SEM      pPtzSeqSem;
IPZ_ZBC_EXT SW_SEM 		pCamzoomSyncSem;//平台软件和cam_zoom.a之间的同步信号量kkk 
IPZ_ZBC_EXT SW_SEM 		pViscaSyncSem;	//平台软件和cam_zoom.a之间的同步信号量kkk 


IPZ_ZBC_EXT SW_THREAD powerOnCaminitId;
IPZ_ZBC_EXT SW_THREAD AFMotorId;
IPZ_ZBC_EXT SW_THREAD AutoExposeId;
IPZ_ZBC_EXT SW_THREAD Get3AdataId;
IPZ_ZBC_EXT SW_THREAD AutoICRId;		//自动ICR进程
IPZ_ZBC_EXT SW_THREAD UartCmdProcessId;//串口处理
IPZ_ZBC_EXT SW_THREAD UartCmdReceiveId;
IPZ_ZBC_EXT SW_THREAD VdIrqId;

/* 平台下发的机芯初始化参数 */
typedef struct _IPZ_ZBC_WEB_PARAM
{
    IPZ_ZBC_DEV_PRD_TYPE eDevType;
    SW_UINT32   u32Fps;
    SW_UINT32   u32height;
    SW_UINT32   u32width;
    IPZ_ZBC_DOME_MODE_E enMode;        
    IPZ_ZBC_DOME_STATE_E enState;      /**< Dome state, RW Only for MANUAL mode, RO for AUTO mode */
    SW_UINT32 u32Delay;               /**< Only for AUTO mode, after <delay> seconds begin to detect dome */
    
}IPZ_ZBC_WEB_PARAM;

void IPZ_ZBC_ThreadCreat(void);
void IPZ_ZBC_SemCreate(void);
SW_INT8 IPZ_ZBC_ZoomBoxInit (void);
SW_INT32 IPZ_ZBC_IRISLevel2Pwm( SW_INT32	idx);
SW_INT32 IPZ_ZBC_IRISPwm2Level( SW_INT32	pwm);
SW_INT8 IPZ_ZBC_IRISOpen(void);
SW_INT8 IPZ_ZBC_IRISClose(void);
SW_INT8 IPZ_ZBC_ZoomTeleRun(void);
SW_INT8  IPZ_ZBC_ZoomWideRun(void);
SW_INT8 IPZ_ZBC_ZoomTWStop(void);
SW_INT8  IPZ_ZBC_FocusFarRun(void);
SW_INT8  IPZ_ZBC_FocusNearRun(void);
SW_INT8  IPZ_ZBC_FocusNTStop(void);
IPZ_ZBC_DEV_PRD_TYPE IPZ_ZBC_WEB_GetDevType(void);
SW_INT IPZ_ZBC_WEB_SetDevType(SW_INT32 iDevType);
SW_UINT32 IPZ_ZBC_WEB_GetFPS(void);
SW_INT IPZ_ZBC_WEB_SetFPS(SW_UINT32 u32Fps);
IPZ_ZBC_DOME_STATE_E IPZ_ZBC_WEB_GetDomeStatus(void);
SW_INT IPZ_ZBC_WEB_SetDomeStatus(IPZ_ZBC_DOME_STATE_E enState);
IPZ_ZBC_DOME_MODE_E IPZ_ZBC_WEB_GetDomeMode(void);
SW_INT IPZ_ZBC_WEB_SetDomeMode(IPZ_ZBC_DOME_MODE_E enMode);
SW_UINT32 IPZ_ZBC_WEB_GetDomeDelay(void);
SW_INT IPZ_ZBC_WEB_SetDomeDelay(SW_UINT32 u32Delay);
SW_INT32 IPZ_ZBC_FIZCmd(IPZ_ZBC_FIZ_CMD cmd, SW_INT32 arg);
SW_INT32 IPZ_ZBC_T2Cmd(IPZ_ZBC_T2_CMD cmd, SW_INT32 arg);
SW_INT32 IPZ_ZBC_GetVersion(void);
SW_RET IPZ_ZBC_CMD_GetCurveZoom(SW_UINT16 *lenth,SW_INT16 *curve);
SW_RET IPZ_ZBC_CMD_ReadCurveFocus(SW_INT16 curve[8][200]);
SW_RET IPZ_ZBC_CMD_DeleteCurve(void);
SW_RET IPZ_ZBC_CMD_ZoomPosition(SW_INT32 *z);
SW_RET IPZ_ZBC_CMD_PTPosition(SW_INT32 *p,SW_INT32 *t);
SW_INT32 IPZ_ZBC_CMD_SetICR(SW_INT32 value);
SW_INT32 IPZ_ZBC_API_GetFocusCoord(void);
SW_INT32 IPZ_ZBC_API_GetZoomCoord(void);
SW_INT32 IPZ_ZBC_API_GotoZoomFocus(SW_INT32 zoom,SW_INT32 focus);
void IPZ_ZBC_API_SetPanTilt(int pan,int tilt);
SW_INT32 IPZ_ZBC_SetDomeDetect(void);
SW_INT32 IPZ_ZBC_API_GotoZoomRation(int zoomRation);
SW_RET IPZ_ZBC_SetTempShiftState(SW_INT bTempDectState);
void IPZ_ZBC_API_SetApertAdjustState(unsigned int s32ApertAdjustState);
SW_RET IPZ_ZBC_SetIRISMaxLimit(SW_INT32 i32IrisMaxLimit);
SW_RET IPZ_ZBC_SetIRISMinLimit(SW_INT32 i32IrisMinLimit);


#endif
